//
//  YHMyMachineInfoListCell.m
//  YHApp
//
//  Created by -- on 2021/7/23.
//

#import "YHMyMachineInfoListCell.h"
#import "YHMyMachineInfoListModel.h"

@interface YHMyMachineInfoListCell ()

/***/
@property (nonatomic, strong) UIView *mainV;
/***/
@property (nonatomic, strong) UIView *lineV;
/***/
@property (nonatomic, strong) UIImageView *rImgV;
/***/
@property (nonatomic, strong) UILabel *titL;
/***/
@property (nonatomic, strong) UILabel *conL;
/***/
@property (nonatomic, strong) UILabel *staL;

@end

@implementation YHMyMachineInfoListCell

-(void)setModel:(YHMyMachineInfoListModel *)model {
    _model = model;
    
    self.titL.text = _model.agent;
    self.conL.text = [NSString stringWithFormat:@"型号:%@  SN:%@",_model.name,_model.sn];
    self.staL.text = _model.state_label;
}

-(void)layoutSubviews {
    [super layoutSubviews];
    
    [self.mainV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    
    [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(-20);
        make.height.mas_offset(1);
        make.bottom.mas_equalTo(0);
    }];
    
    [self.rImgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.right.mas_equalTo(-20);
        make.width.mas_offset(5);
        make.height.mas_offset(10);
    }];
    
    [self.staL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.rImgV.mas_left).offset(-6);
        make.centerY.mas_equalTo(0);
        make.width.mas_offset(52);
    }];
    
    [self.titL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(self.staL.mas_left).offset(-10);
        make.centerY.mas_equalTo(-13);
    }];
    
    [self.conL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(self.staL.mas_left).offset(-10);
        make.centerY.mas_equalTo(13);
    }];
}

- (UIView *)mainV
{
    if (!_mainV) {
        _mainV = [UIView ha_createView];
        _mainV.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_mainV];
    }
    return _mainV;
}

- (UIView *)lineV
{
    if (!_lineV) {
        _lineV = [UIView ha_createView];
        _lineV.backgroundColor = [UIColor khaBGColor];
        [self.mainV addSubview:_lineV];
    }
    return _lineV;
}

- (UIImageView *)rImgV
{
    if (!_rImgV) {
        _rImgV = [UIImageView ha_createImageView];
        _rImgV.image = [UIImage imageNamed:@"ic_cell_more"];
        [self.mainV addSubview:_rImgV];
    }
    return _rImgV;
}

- (UILabel *)titL
{
    if (!_titL) {
        _titL = [UILabel ha_NLabelWithFont:18 textColor:@"#111a34" text:@"" alignment:0];
        [self.mainV addSubview:_titL];
    }
    return _titL;
}

- (UILabel *)conL
{
    if (!_conL) {
        _conL = [UILabel ha_NLabelWithFont:12 textColor:@"#858b9c" text:@"" alignment:0];
        [self.mainV addSubview:_conL];
    }
    return _conL;
}

- (UILabel *)staL
{
    if (!_staL) {
        _staL = [UILabel ha_NLabelWithFont:15 textColor:@"#858b9c" text:@"" alignment:2];
        [self.mainV addSubview:_staL];
    }
    return _staL;
}

@end
